<template>
	<view class="app">
		<load :ready="ready"></load>
		
		
		
		<template v-if="info">
			
			<view class="fixed-btn2" @click="makePhoneCall('0731-55555184')">
				<view class="phone">
					<u-icon name="phone-fill" size="42" color="#0093dd"></u-icon>
					<view class="text">
						电话咨询
					</view>
				</view>
			</view>	

			<view class="order-warp">
				<view class="goods-list">
					<view class="item" v-for="(item, index) in cardList" v-if="item.type==1" :key="item.id">
						<u-image width="180rpx" height="180rpx" :src="item.image"></u-image>
						<view class="info">
							<view class="name">{{item.name}}</view>
							<view class="text txt-hide2">{{item.description}}</view>
							<view class="btnbox">
								<view class="price">￥ <text style="padding-left: 4px;">{{item.price}}</text></view>
								<view class="view">
									<u-number-box class="jinyong" size="24" input-width="60" :min="1" :max="getMaxNum"  v-model="item.num"
										 @minus="onMinus($event, item)" :maxTip="true" @plus="onPlus($event, item)"></u-number-box>
                                         
								</view>
							</view>
							<view class="tips" style="text-align: right;">
								<text v-if="form.displace_or_add == 1">
								需回收空共享瓶{{item.num}}个
								</text>
							</view>
						</view>

					</view>
				</view>
			</view>

			<view class="ibox">
				<view class="titlebox">
					<image src="/static/icon_add.png" mode="widthFix" class="icon"></image>
					<text>配送地址</text>
				</view>
				<view class="addres-wrap">
					<view class="info" v-if="userInfo.telephone">
						<view class="addhead">
							<text class="name">{{userInfo.name}}</text>
							<text class="mobile">{{userInfo.telephone}}</text>
						</view>
						<view class="text">
							{{userInfo.address}}{{userInfo.address_detail}}
						</view>
					</view>
					<view class="info" v-else style="width: 100%;">
						<u-button type="success" @click="link('/pages/user/addres_info')">
							<u-icon name="plus-circle" size="32rpx"></u-icon>
							新增地址
						</u-button>
					</view>
				</view>
			</view>

			<!-- <view class="ibox">
				<view class="titlebox" style="padding-bottom: 0;">
					<image src="/static/icon_state3.png" mode="widthFix" class="icon"></image>
					<text>开户合同</text>
				</view>
				<view class="-mlr-32rpx">
					<u-cell-group :border="false">
						<u-cell-item :border-bottom="false" @click="link('./signing')" title="喜威新增钢瓶电子合同" value="去签约">
						</u-cell-item>
					</u-cell-group>
				</view>
			</view> -->

			<view class="ibox">
				<view class="titlebox" style="padding-bottom: 0;">
					<image src="/static/icon_invoice.png" mode="widthFix" class="icon"></image>
					<text>下单信息</text>
				</view>
				<u-form :model="form" label-position="left" labelWidth="140" ref="uForm">
					<u-form-item label="类型" :border-bottom="false">
						
						<u-radio-group v-model="form.displace_or_add" @change="radioGroupChange">
							<u-radio @tapDisabled="onTapDisabled" v-for="(item, index) in displaceType" :key="index" :disabled="item.disabled" :name="item.value">
						
							<!-- <u-radio @tapDisabled="onTapDisabled" v-for="(item, index) in displaceType" :key="index" :name="item.value"> -->
								<!--  -->
								{{ item.name }}
							</u-radio>
						</u-radio-group>
					</u-form-item> 
					
					<view class="desc-list u-border-bottom">
						<view class="text">
							新增共享瓶：当新用户还没共享瓶时需先租用共享瓶才可订气
						</view>
						<view class="text">
							共享瓶订气：当有共享瓶时选择此类型，送气工将以实瓶换走空瓶
						</view>
						<view class="text">
							旧瓶回收：如果有旧瓶想换共享瓶，送气工可上门对旧瓶进行收购
						</view>
					</view>
					
					<u-form-item label="配送时间">
						7：00~19：00下单，立即配送
					</u-form-item>
					<!-- 	<u-form-item label="楼层费" >
						<u-input v-model="form.stair"  placeholder="步梯2楼收1元，2楼以上每层加收1元"
							type="select" />
					</u-form-item> -->
					<!-- <u-form-item label="发票信息" >
						<u-input v-model="form.sex"  placeholder="请选择发票信息"
							type="select" />
					</u-form-item> -->
					
					
					<view class="recovery-label">
						<view class="recovery-name">
							是否需要旧瓶回收服务
						</view>
						<view class="recovery-tips" @click="showRule=true">
							“重要：钢瓶回收折价说明
						</view>
					</view>
					<u-form-item label=" " label-position="top">
						<u-radio-group v-model="form.is_recovery">
							<u-radio v-for="(item, index) in isRecovery" :key="index" :name="item.value"
								:disabled="item.disabled">
								{{ item.name }}
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="备注" :border-bottom="false" label-position="top">
						<u-input v-model="form.user_remark" placeholder="选填：给商家的留言信息" type="textarea" />
					</u-form-item>
				</u-form>
			</view>
			

			<view class="ibox">
				<view class="titlebox">
					<image src="/static/icon_trolley.png" mode="widthFix" class="icon"></image>
					<text>商品增购</text>
				</view>
				<view style="margin: 0 -30rpx;">
					<scroll-view class="scrollx" scroll-x="true">
						<!-- 	<view class="scrollx-item" v-for="(item, index) in goodsList" @click="link('./goods_info?id=1')"> -->
						<view class="scrollx-item" v-for="(item, index) in goodsList" :key="item.id">
							<u-image width="260rpx" height="240rpx" :src="item.image"></u-image>
							<view class="info">
								<view class="name">{{item.name}}</view>
								<view class="btnbox">
									<view class="price">￥<text>{{item.price}}</text></view>
									<view class="numberbox">
										<u-number-box class="jinyong" size="24" input-width="60"  v-model="item.num"
                                             @minus="onMinus2($event, item)" :maxTip="true" @plus="onPlus2($event, item)"
											 ></u-number-box>
									</view>
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
			</view>

			<view class="ibox"  v-if="oInfo.totalPrice">
				<view class="titlebox">
					<image src="/static/icon_wallet.png" mode="widthFix" class="icon"></image>
					<text>付款信息</text>
				</view>
				<view class="desc-text"  @click="showDeposit=true">
					<view class="label">
						共享瓶押金
						<u-icon size="28" name="info-circle"></u-icon>
					</view>
					<view class="value">¥{{oInfo.deposit}}</view>
					<!-- <view >
						<view class="value">¥{{bottle_deposit}}</view>
					</view> -->
				</view>
				
				<!-- <view class="desc-text">
					<view class="label">共享瓶租金</view>
					<view style="text-align: right; font-size: 24rpx; color: #999;">
						<view class="value"><u-icon size="28" name="info-circle"></u-icon> ¥<text>{{bottle_rent}}</text>一个月，半年结算一次</view>
					</view>
				</view> -->
				
				<view class="desc-text" @click="showRent=true">
					<view class="label">
						共享瓶租金
						<u-icon size="28" name="info-circle"></u-icon>
						<text class="color" @click.stop="link('/pages/user/bottle?current=1')">查看租金结算记录</text>
					</view>
					<!-- <view class="value">¥<text>{{bottle_rent}}</text></view> -->
					<view class="value">¥<text>{{oInfo.rent}}</text></view>
				</view>
				
			<!-- 	<view class="desc-text">
					<view class="label">钢瓶使用费(年)</view>
					<view class="value">¥{{oInfo.rent}}</view>
				</view> -->
				<view class="desc-text" @click="showAddTip=true">
					<view class="label">楼层费<u-icon size="28" name="info-circle"></u-icon></view>
					<view class="value">¥{{oInfo.floorCost}}</view>
				</view>
				
				<view class="desc-text">
					<view class="label">气价</view>
					<view class="value">¥{{oInfo.price}}</view>
				</view>
				<view class="desc-text">
					<view class="label">商品增购</view>
					<view class="value">¥{{oInfo.additionalPrice}}</view>
				</view>
				<!-- <view class="desc-text">
					<view class="label">优惠券扣减</view>
					<view class="value">-¥{{oInfo.order.totalPrice}}</view>
				</view> -->
				
				<view class="desc-text">
					<view class="label">实际付款金额</view>
					<view class="value">¥{{total || oInfo.totalPrice}}</view>
				</view>
				<u-gap height="20"></u-gap>
			</view>

			<view style="height: 120rpx;"></view>
			<view class="order-foot" v-if="oInfo.totalPrice">
				<view class="total">支付合计：￥<text>{{total || oInfo.totalPrice}}</text></view>
				<view class="right">
					<u-button class="btn" @click="submit()" type="success" hover-class="none" :custom-style="{
						...btnStyle,
					}">确认提交</u-button>
				</view>
			</view>
		</template>
		
		<u-select v-model="showStair" :list="stairList" @confirm="confirm($event,'stair')"></u-select>
		<u-modal v-model="showTips" @confirm="submit(false)" :show-cancel-button="true"
			:content="`已超出今日配送时间段，订单可能于明天早上进行配送，是否继续下单，如继续下单则订单配送时间为${nextDate.result} 9:00~12:00 ？`"></u-modal>
			
			
			<u-popup v-model="showRule" :closeable="true" mode="bottom" height="600">
				<view class="content-desc">
					<view class="title">钢瓶回收折价说明</view>
					 <u-parse :html="content"></u-parse>
				</view>
			</u-popup>
			
			<u-popup v-model="showRent" :closeable="true" mode="bottom" height="400">
				<view class="content-desc">
					<view class="title">共享瓶租金说明</view>
					<view class="text">
						共享瓶租金{{bottle_rent}}元/天
					</view>
					<view class="text">
						租金结算规则：当订单配送完成时，根据取回空瓶的使用天数进行计算，并于下次订气时收取租金。
					</view>
					<!-- <view class="text">
						押瓶押金 {{bottle_deposit}}
					</view>
					<view class="text">
						钢瓶租金按天计费
					</view> -->
				</view>
			</u-popup>
			
			<u-popup v-model="showAddTip" :closeable="true" mode="bottom" height="300">
				<view class="content-desc">
					<view class="title">楼层费说明</view>
					<view class="text">步梯2楼收{{floor}}元，2楼以上每层加收{{floor}}元</view>
				</view>
			</u-popup>
			
			<u-popup v-model="showDeposit" :closeable="true" mode="bottom" height="300">
				<view class="content-desc">
					<view class="title">共享瓶押金说明</view>
					<view class="text">共享瓶押金，随时可退</view>
				</view>
			</u-popup>
			
			<u-modal v-model="showTips2" @confirm="showTips2=false" :show-cancel-button="false"
				content="您当前没有共享瓶，请先新增共享瓶"></u-modal>
	</view>
</template>



<script>
	import {
		mapState,
		mapActions,
		mapMutations,
		mapGetters
	} from 'vuex';
	import {
		mixinsBase
	} from '@/common/js/mixins';
	let that;
	export default {
		mixins: [mixinsBase],
		components: {},
		data() {
			let myDate = new Date();
			let stairList = [];
			for (let i = 1; i < 15; i++) {
				stairList.push({
					label: `${i}楼`,
					value: i,
				})
			}

			return {
				showAddTip:false,
				isRecovery: [{
						name: '是',
						value: 1,
						disabled: false
					},
					{
						name: '否',
						value: 0,
						disabled: false
					}
				],
				ready: false,
				btnStyle: {
					background: '#497CD0',
					borderRadius: '8px',
					padding: '0 25px',
				},
				id: null,
				// info:null,
				orderRemark: '',
				showShip: true,
				form: {
					is_recovery: 0,
					user_remark:'',
					displace_or_add:1,//1共享瓶订气2新增共享瓶
				},
				displaceType: [{
						name: '共享瓶订气',
						value: 1,
						disabled: false
					},
					{
						name: '新增共享瓶',
						value: 2,
						disabled: false
					}
				],
				value: 0,
				myDate,
				date: myDate.getHours(),
				maxDate: 16,
				showTips: false,
				nextDate: this.$dateUitl.getDateStr(1),
				stairList,
				showStair: false,
				goodsList: [],
				info:{},
				oInfo:{},
				cardList:[],
				content:'',
				showRule:false,
				bottle_deposit:0,
				bottle_rent:0,
				floor:0,
				showRent:false,
				oid:null,
				goodsPrice:{},
				total:'',
				prePrice:null, //优惠
				floorCost:null,
				showTips2:false,
				showDeposit:false,
			};
		},
		onLoad(o) {
			that = this;
			this.getInit();
			this.getList();
		},
		onReady() {},
		onShow() {
			// this.getInit();
				// this.getUserInfo();
		},
		onUnload() {
			that = null;
		},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {
			// this.getInit(data=>{
			//      uni.stopPullDownRefresh();
			//      common.showTip('刷新成功');
			// });
		},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {
			//       return {
			// 	// path,
			// 	imageUrl:config.shareImg,
			// 	// title
			// }
		},
		methods: {
			makePhoneCall(num){
				this.$common.makePhoneCall(num)
			}, 	
			async getUserInfo(){
				try{
					let res = await this.$api.getUserList();
					if(res.data.id){
						res.data = this.$user.normalFilter(res.data)
						let userInfo = {
							...this.userInfo,
							...res.data,
						}
						if(!userInfo.address){
						this.setUserInfo(userInfo)
						if(!this.isTips){
							this.isTips = true
							const [err, res] = await uni.showModal({
									title:'提示',
									content:'当前没有配送地址，是否去新建地址？',
									cancelText:'取消',
									confirmText:'确认',
								})
								if(res.confirm){
									this.link('/pages/user/addres_info')
								}
							}
						}	
					} else{
						// uni.removeStorageSync('userInfo')
						// uni.reLaunch({
						// 	url:'/pages/login/login'
						// })
					}
				}catch(e){
					//TODO handle the exception
					// uni.removeStorageSync('userInfo')
					// uni.reLaunch({
					// 	url:'/pages/login/login'
					// })
				}
			},
			onTapDisabled(e){
				console.log('--onTapDisabled--')
				this.showTips2 = true
			},
			radioGroupChange(e){
				console.log('-----')
				console.log(e);
				this.updataNum();
                if(e==1){
                    //共享瓶押金
                    this.$set(this.oInfo, 'deposit',0)
                }
				this.getTotal();
				// this.payMessage();
			},
			async updataNum(){
				this.$set(this.cardList[0],'num', 1);
				this.$set(this.cardList[0],'price', this.goodsPrice[this.cardList[0].id]);
				let params = {
					goods_id: this.cardList[0].id,
					num:1,
					calc:'add',
				}
				await this.$api.bookingNew(params);
			},
			valChange(e, item) {
				console.log(e, item)
			},
			onMinus(e, item) {
				// uni.showLoading();
				console.log(e, item)
				this.$set(item, 'price', this.$common.accMul(item.num, this.goodsPrice[item.id]));
				this.getTotal();
				this.booking(item.id, 'reduce', false)
			},
			onPlus(e, item) {
				// uni.showLoading();
				console.log(e, item)
				this.$set(item, 'price', this.$common.accMul(item.num, this.goodsPrice[item.id]));
				this.getTotal();
				this.booking(item.id, 'add' ,false)
			},
			onMinus2(e, item) {
				// uni.showLoading();
				console.log(e, item)
				if(e.value > 0 ){
					this.getTotal();
					this.booking(item.id, 'reduce')
				} else{
					// this.$set(item, 'num', 0);
					this.getTotal();
					this.delCart(item.id);
				}
			},
			onPlus2(e, item) {
				// uni.showLoading();
                console.log(e, item)
				this.getTotal();
				this.booking(item.id, 'add')
				// if(item.num == 0){
				// 	this.booking(item.id)
				// } else{
					
				// }
			},
            changeValue(e) {
            	console.log('返回数值：', e);
            },
			confirm(e, name) {
				if (name == 'stair') {
					this.form.stairData = e[0];
					this.form.stair = e[0].label;
				}
			},
			async delCart(id) {
				if(this.isDelCart)return
				this.isDelCart = true;
				let res = await this.$api.delCart({
					goods_id:id,
				});
				this.isDelCart = false
				if (res.data.code == this.$config.RESOK) {
					// this.getInit();
					// this.$message.error(res.data.msg);
				}
			},
			async submit(isTime=true) {
				this.showTips = false;
				this.$refs.uForm.validate(valid => {
					if (valid) {
						console.log('验证通过');
					} else {
						console.log('验证失败');
					}
				});
				
				// if (isTime && this.date > this.maxDate) {
				// 	this.showTips = true;
				// 	return
				// }
				uni.showLoading();
				
				let params = {
					...this.form,
					consignee:this.userInfo.name,
					address:this.userInfo.address + this.userInfo.address_detail,
					mobile:this.userInfo.telephone,
					// telephone:this.userInfo.telephone,
				}
				let res = await this.$api.smOrder(params);
				uni.hideLoading();
				if (res.data.code == this.$config.RESOK) {
					
					this.oid = res.data.data.order_id;
					this.pay();
					// this.$message.success(res.data.msg);
					// setTimeout(()=> {
					// 	uni.redirectTo({
					// 		url: `/pages/index/pay?id=${res.data.data.order_id}`,
					// 	});
					// 	this.link(`/pages/index/pay?id=${res.data.data.order_id}`)
					// }, 2000);
					
				} else{
					this.$message.error(res.data.msg);
					// setTimeout(()=> {
					// 	this.$common.goback();
					// }, 2000);
				}
			},
			async pay(){
				this.isLoading=true;
				const that = this;
				uni.showLoading();
				let res = await this.$api.payMoney({
					order_id: this.oid,
				});
				this.isLoading = false;
				uni.hideLoading();
				if (res.data.code == this.$config.RESOK) {
					
					if(JSON.stringify(res.data.data) == '[]' ){
						that.$common.showTip('支付成功','success');
						setTimeout(() => {
						    uni.redirectTo({
								url: `/pages/user/order_info?id=${that.oid}`,
							});
						}, that.$config.timeLoad);
						return
					}
					const paydata = res.data.data;
					// this.$message.success(res.data.msg);
					uni.requestPayment({
					    provider: 'wxpay',
					    timeStamp: paydata.timeStamp,
					    nonceStr: paydata.nonceStr,
					    package: paydata.package,
					    signType: paydata.signType,
					    paySign: paydata.paySign,
					    success: function(res) {
					        console.log(res);
					        that.$common.showTip('支付成功','success');
							console.log("res: " + JSON.stringify(res));
					        setTimeout(() => {
					            uni.redirectTo({
									url: `/pages/user/order_info?id=${that.oid}`,
								});
					        }, that.$config.timeLoad);
					    },
					    fail: function(err) {
					        console.log('fail:' + JSON.stringify(err));
					        let text = '支付失败:'+err.errMsg;
					        if(err.errMsg == 'requestPayment:fail cancel'){
					            text = '支付取消';
					        }
					        that.$common.showTip(text,'none');
							setTimeout(()=> {
								that.$common.goback();
							}, 2000);
					    }
					});
					// setTimeout(()=> {
					// 	uni.redirectTo({
					// 		url: `/pages/user/order_info?id=${this.id}`,
					// 	});
					// }, 2000);
				} else {
					this.$message.error(res.data.msg);
				}
			},
			async nextSubmit() {
				let res = await this.$api.logCompany();
				if (res.data.code == this.$config.RESOK) {} else {
					this.$message.error(res.data.msg);
				}
			},
			
			async booking(id,type=null,updata=true ){
				// add 是加1  reduce是减1
				let params = {
					goods_id: id
				}
				if(type){
					params.calc = type;
				}
				let res = await this.$api.booking(params);
				if (res.data.code == this.$config.RESOK) {
					// this.getInit();
					if(updata){
						this.cardList = res.data.data;
					}
					// this.payMessage();
				} else {
					this.$message.error(res.data.msg);
				}
			},
			
			async getInit() {
				if( !this.content.length ){
					const [resContent,resDeposit, resRent, resFloor] = await Promise.all([
						this.$api.showMsg(),
						this.$api.showConfig({
							 type:'pay',
							 name:'bottle_rent'
						}),
						this.$api.showConfig({
							 type:'pay',
							 name:'bottle_deposit'
						}),
						this.$api.showConfig({
							 type:'pay',
							 name:'floor'
						}),
					])
					if (resContent.data.code == this.$config.RESOK) {
						this.content = resContent.data.data.discount;
					} 
					if (resDeposit.data.code == this.$config.RESOK) {
						  this.bottle_rent = resDeposit.data.data
					} 
					if (resRent.data.code == this.$config.RESOK) {
						 this.bottle_deposit = resRent.data.data
					} 
					if (resFloor.data.code == this.$config.RESOK) {
						 this.floor = resFloor.data.data
					} 
					// const [resContent,resDeposit, resRent] = await Promise.all([
					// 	this.$api.showMsg(),
					// 	this.$api.showConfig({
					// 		 type:'pay',
					// 		 name:'bottle_deposit'
					// 	}),
					// 	this.$api.showConfig({
					// 		 type:'pay',
					// 		 name:'bottle_rent'
					// 	}),
					// 	this.$api.showConfig({
					// 		 type:'pay',
					// 		 name:'floor'
					// 	}),
					// ])
					// if (resContent.data.code == this.$config.RESOK) {
					// 	this.content = resContent.data.data.discount;
					// } 
					// if (resDeposit.data.code == this.$config.RESOK) {
					// 	 this.bottle_deposit = resDeposit.data.data
					// } 
					// if (resRent.data.code == this.$config.RESOK) {
					// 	 this.bottle_rent = resRent.data.data
					// } 
					// if (resFloor.data.code == this.$config.RESOK) {
					// 	 this.floor = resFloor.data.data
					// } 
				}
				let res =  await this.$api.bookingList();
				
				if (res.data.code == this.$config.RESOK) {
					res.data.data.forEach(item=>{
						this.goodsPrice[item.id] = item.price;
					})
					this.cardList = res.data.data;
					this.payMessage();
				} else {
					this.$message.error(res.data.msg);
				}
			},
			async payMessage(){
				let res = await this.$api.payMessage({
					displace_or_add: this.form.displace_or_add,
				});
				uni.hideLoading();
				if (res.data.code == this.$config.RESOK) {
					let oInfo = res.data.data;
                    console.log("查询oInfo",oInfo,oInfo.deposit)
					let totalPrice = this.$common.accAdd(oInfo.deposit, oInfo.floorCost)
					this.prePrice = oInfo.discount_amount;
					totalPrice = this.$common.accAdd(totalPrice, oInfo.rent)
					totalPrice = this.$common.accAdd(totalPrice, oInfo.price)
					totalPrice = this.$common.accAdd(totalPrice, oInfo.additionalPrice)
					// let total = 0;
					// this.cardList.forEach(item=>{
					// 	let pri = this.$common.accMul(item.price, item.num)
					// 	total = this.$common.accAdd(pri, total)
					// }) 
					// console.log('total', total)
					// oInfo.totalPrice = this.$common.accAdd(totalPrice, total);
					oInfo.totalPrice = totalPrice;
					this.oInfo = oInfo;
					this.floorCost = oInfo.floorCost;
					//第一次检测
					if(!this.isCan){
						this.isCan = true
						if(oInfo.bottle_num == 0){
							this.form.displace_or_add = 2;
							this.displaceType[0].disabled = true;
							this.$nextTick(()=>{
								this.payMessage();
							})
						} else{
							this.getTotal();
							this.ready=true;
						}
					} else{
						this.getTotal();
						this.ready=true;
					}
					// deposit: 150  押金
					// floorCost: 0  楼层费用
					// goodsNum: 1  主商品数量
					// newNum: 1
					// price: 100  气价
					// rent: "36.00"  钢瓶使用费
				} else{
					this.$common.showTip(res.data.msg)
				}
			},
			async getList() {
				// let res = await this.$api.bookingList();
				// "type = 1(新品推荐);2(好物优选);3(猜你喜欢);4(热销商品)",
				let res = await this.$api.goodsList({
					type:2,
				});
				if (res.data.code == this.$config.RESOK) {
					let list = res.data.data.data
					list.forEach(item=>{
						// item.image = this.$config.httpImgs + item.image
						let cardData = this.cardList.find(card=>card.id == item.id) || null;
						item.num  = 0
						if(cardData){
							item.num = cardData.num;
						}
						this.goodsPrice[item.id] = item.price;
					})
					this.goodsList = list
				} else {
					this.$message.error(res.data.msg);
				}
			},
			getTotal(){
				let total = 0;
				let oInfo = this.oInfo;
				let price = 0;
				let additionalPrice = 0;
				let num = 0;
				
				
				if(this.oInfo.rent){
					total = this.$common.accAdd(this.oInfo.rent, total);
					this.$set(this.oInfo, 'rent', this.oInfo.rent)
				}
				console.log('total  this.oInfo.rent', total)
				// if(this.userInfo.bottle_rent){
				// 	total = this.$common.accAdd(this.userInfo.bottle_rent, total);
				// 	this.$set(this.oInfo, 'rent', this.userInfo.bottle_rent)
				// } 
				this.cardList.forEach(item=>{
                    console.log("item",item)
					if(item.type == 1){
						price = this.$common.accAdd(this.$common.accMul(item.num, this.goodsPrice[item.id]), price);
						num += item.num
					}
				})
                console.log("num数量",num)
				
				if(this.prePrice){
					console.log('---------this.prePrice-this.prePrice')
					price = this.$common.subtr(price,this.prePrice);
				}
				
				this.$set(this.oInfo, 'price', price)
				this.goodsList.forEach(item=>{
					if(item.num){
						additionalPrice = this.$common.accAdd(this.$common.accMul(item.num, this.goodsPrice[item.id]), additionalPrice);
					}
				})
				console.log('total --- price',total,price);
				console.log(this.$common.accAdd(total, price));
				total = this.$common.accAdd(total, price);
				
			
				if(additionalPrice){
					total = this.$common.accAdd(total, additionalPrice);
					this.$set(this.oInfo, 'additionalPrice', additionalPrice)
				} else{
					this.$set(this.oInfo, 'additionalPrice', 0)
				}
				
				//用户表有的情况下直接相加
				if(this.userInfo.bottle_deposit){
                    let bottle_deposit = 0
                    //如果是新增
                    if( this.form.displace_or_add == 2){
                        bottle_deposit =  this.$common.accMul(this.userInfo.bottle_deposit, num)
                        console.log("新增押瓶类型",bottle_deposit)
                    }else{
                        console.log("置换押瓶",bottle_deposit)
                    }
                   
					this.$set(this.oInfo, 'deposit', bottle_deposit)
                    console.log("我乘以数量11",bottle_deposit)
                    console.log('bottle_deposit',bottle_deposit, 'num', num);
					total = this.$common.accAdd(total, bottle_deposit);
					
				} else if( this.form.displace_or_add == 2){
					
					let bottle_deposit =  this.$common.accMul(this.bottle_deposit, num)
					 console.log("我乘以数量22",bottle_deposit)
                    console.log('bottle_deposit',bottle_deposit, 'num', num);
                    
					this.$set(this.oInfo, 'deposit', bottle_deposit)
					total = this.$common.accAdd(total, bottle_deposit);
				}
				
				//不用计算押金
				// if( this.form.displace_or_add == 1){
				// } else{
				// 	// let bottle_deposit =  this.$common.accMul(this.bottle_deposit, num)
				// 	let bottle_deposit =  this.$common.accMul(this.userInfo.bottle_deposit || this.bottle_deposit, num)
				// 	console.log('bottle_deposit',bottle_deposit, 'num', num);
				// 	this.$set(this.oInfo, 'deposit', bottle_deposit)
				// 	total = this.$common.accAdd(total, bottle_deposit);
				// }
				//楼层费
				if(this.floorCost){
					let floorCost =this.$common.accMul(this.floorCost , num)
					console.log('floorCost楼层费',floorCost)
					total = this.$common.accAdd(total, floorCost);
					this.$set(this.oInfo, 'floorCost', floorCost)
				}
				this.total = total;
			},
			radioChange() {

			},
			handleTab(e) {
				this.tab = e;
			},
			change(e) {
				this.current = e;
			},
			...mapActions(['setUserInfo']),
		},
		computed: {
			...mapState({
				userInfo: 'userInfo'
			}),
			getMaxNum(){
				if(this.form.displace_or_add == 2){
					return 9999
				}
				return this.oInfo.bottle_num || 1
			},
		}
	};
</script>

<style>
	page {
		background-color: #f5f5f5;
	}
    .jinyong input{pointer-events: none;}
</style>
<style scoped lang="scss">
	page {
		background-color: #f5f5f5;
	}
    
	.order-warp {
		background: #497CD0;
		padding: 24rpx 32rpx;

		.state {
			display: flex;
			color: #fff;
			align-items: center;

			.icon {
				width: 28px;
				height: 28px;
			}

			text {
				margin-left: 6px;
				font-size: 20px;
			}
		}


	}

	.ibox {
		background: #fff;
		margin: 16rpx 32rpx;
		border-radius: 12px;
		padding: 0 32rpx;

		.log-item {
			display: flex;
			align-items: center;
			padding: 4px 0;

			text {
				margin-right: 10px;
			}

			.icon-copy {
				width: 18px;
				height: 18px;
			}
		}
	}

	.titlebox {
		display: flex;
		padding: 28rpx 0;
		align-items: center;

		.icon {
			width: 18px;
			height: 18px;
		}

		text {
			margin-left: 5px;
			font-size: 16px;
		}
	}

	.goods-list {
		border: 0;
		.item{
			padding: 10rpx 0
		}
		.btnbox{
			padding-top: 16rpx;
		}
	}

	.desc-text {
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #8E8E9A;
		padding: 4px 0;
		.color{
			color: $color;
			font-size: 12px;
			text-decoration: underline;
			margin-left: 4px;
		}
	}

	.order-foot {
		padding: 10rpx 30rpx;
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 99;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-shadow: 0 0 20px #ddd;

		.total {
			color: #333;

			text {
				font-size: 18px;
				font-weight: bold;
			}
		}
	}

	.send-popup {
		padding: 20rpx 30rpx;
		position: relative;

		.btn-close {
			position: absolute;
			right: 30rpx;
			top: 20rpx;
		}

		.title {
			text-align: center;
			font-size: 16px;
			margin-bottom: 20rpx;
		}

		.item {
			margin-bottom: 20rpx;
		}

		.label {
			font-size: 14px;
			margin-bottom: 6px;
		}

		.btnbox {
			padding-top: 30rpx;
		}
	}

	.attrbox {
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 12px;
		padding: 2px 0;
		color: #666;

		.attr-name {
			width: 80%;
			font-size: 12px;
		}

		.num {}
	}

	.sell {
		padding: 10px 0;
		color: #666;
	}

	.goods-list {
		background: #fff;
		border-radius: 5px;
		padding: 20rpx;
	}

	.addres-wrap {
		background: #fff;
		border-radius: 12px;
		display: flex;
		justify-content: space-between;
		padding-bottom: 20rpx;

		.name {
			margin-right: 12px;
		}

		.addhead {
			margin-bottom: 4px;
		}

		.text {
			font-size: 14px;
		}
	}

	.recovery-label {
		line-height: 22px;
		padding-top: 16rpx;
		display: flex;

		.recovery-name {
			font-size: 14px;
		}

		.recovery-tips {
			font-size: 12px;
			color: $color;
			text-decoration: underline;
			margin-left: 4px;
		}
	}

	.scrollx-item {
		display: inline-block;
		margin-left: 20rpx;

		&:nth-last-child(1) {
			margin-right: 20rpx
		}

		.info {
			padding: 10rpx 0 20rpx;
		}

		.name {
			font-size: 14px;
			margin-bottom: 5px;
		}

		.price {
			font-size: 12px;

			text {
				font-size: 14px;
			}
		}

		.btnbox {
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
	}
	.content-desc{
		padding: 30rpx;
		.title{
			font-size: 18px;
			font-weight: bold;
			margin-bottom: 20rpx;
		}
	}
	
	.goods-list{
		.view{
			text-align: right;
		}
		.tips{
			color: $color-red;
			font-size: 12px;
			padding-top: 2px;
			// height: 20px;
		}
	}
	
	.fixed-btn2{
		position: fixed;
		right: 20rpx;
		top: 500rpx;
		background: #eee;
		border-radius: 10px;
		z-index: 99;
		width: 50px;
		height: 50px;
		justify-content: center;
		align-items: center;
		display: flex;
		.phone{
			text-align: center;
		}
		.text{
			font-size: 10px;
			text-align: center;
		}
		// border: 1px solid #ccc;
	}
	
	.desc-list{
		padding-bottom: 10px;
		.text{
			padding: 2px 0;
			font-size: 11px;
			text-align: left;
		}
	}
</style>